// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   PieChart.java

package org.achartengine.chart;

import android.graphics.*;
import java.util.ArrayList;
import java.util.List;
import org.achartengine.model.CategorySeries;
import org.achartengine.renderer.DefaultRenderer;
import org.achartengine.renderer.SimpleSeriesRenderer;

// Referenced classes of package org.achartengine.chart:
//			RoundChart

public class PieChart extends RoundChart
{

	public PieChart(CategorySeries categoryseries, DefaultRenderer defaultrenderer)
	{
		super(categoryseries, defaultrenderer);
	}

	public void draw(Canvas canvas, int i, int j, int k, int l, Paint paint)
	{
		paint.setAntiAlias(mRenderer.isAntialiasing());
		paint.setStyle(android.graphics.Paint.Style.FILL);
		paint.setTextSize(mRenderer.getLabelsTextSize());
		int i1 = getLegendSize(mRenderer, l / 5, 0.0F);
		int j1 = i;
		int k1 = j;
		int l1 = i + k;
		int i2 = mDataset.getItemCount();
		double d = 0.0D;
		String as[] = new String[i2];
		for (int j2 = 0; j2 < i2; j2++)
		{
			d += mDataset.getValue(j2);
			as[j2] = mDataset.getCategory(j2);
		}

		if (mRenderer.isFitLegend())
			i1 = drawLegend(canvas, mRenderer, as, j1, l1, j, k, l, i1, paint, true);
		int k2 = (j + l) - i1;
		drawBackground(mRenderer, canvas, i, j, k, l, paint, false, 0);
		float f = 0.0F;
		int l2 = Math.min(Math.abs(l1 - j1), Math.abs(k2 - k1));
		int i3 = (int)((double)l2 * 0.34999999999999998D * (double)mRenderer.getScale());
		if (mCenterX == 0x7fffffff)
			mCenterX = (j1 + l1) / 2;
		if (mCenterY == 0x7fffffff)
			mCenterY = (k2 + k1) / 2;
		float f1 = (float)i3 * 0.9F;
		float f2 = (float)i3 * 1.1F;
		RectF rectf = new RectF(mCenterX - i3, mCenterY - i3, mCenterX + i3, mCenterY + i3);
		ArrayList arraylist = new ArrayList();
		for (int j3 = 0; j3 < i2; j3++)
		{
			paint.setColor(mRenderer.getSeriesRendererAt(j3).getColor());
			float f3 = (float)mDataset.getValue(j3);
			float f4 = (float)(((double)f3 / d) * 360D);
			canvas.drawArc(rectf, f, f4, true, paint);
			drawLabel(canvas, mDataset.getCategory(j3), mRenderer, arraylist, mCenterX, mCenterY, f1, f2, f, f4, j1, l1, paint);
			f += f4;
		}

		arraylist.clear();
		drawLegend(canvas, mRenderer, as, j1, l1, j, k, l, i1, paint, false);
		drawTitle(canvas, i, j, k, paint);
	}
}
